<template>
  <div>
    <r-search
      ref="search"
      :searchData="searchData"
      :searchForm="searchForm"
      :searchHandle="searchHandle"
      :inline="true"
    />

    <!--    <div>共{{total}}条消息</div>-->

    <r-table
      :isPagination="true"
      :isHandle="true"
      :tableData="tableData"
      :tableCols="tableCols"
      :tablePage="pagination"
      :loading="tableLoading"
      :tableHandles="tableHandles"
      :isSelection="false"
      @refresh="getData()"
    />
  </div>
</template>

<script>
export default {
  data() {
    return {
      searchData: {
        type: "",
        phone: "",
        total: "0"
      },
      searchForm: [
        {
          type: "select",
          label: "",
          placeholder: "Submit Type",
          prop: "type",
          width: 230,
          options: [
            { label: "Suggest", value: "1" },
            { label: "Complaint", value: "2" },
            { label: "Else", value: "3" }
          ]
        }
      ],
      searchHandle: [
        {
          type: "primary",
          label: "Search",
          plain: true,
          handle: e => {
            this.zeroFn();
            this.getData();
          }
        }
        // {type:'primary',label:'Reset', handle: e => this.elFormSubmit(),}
      ],

      tableLoading: false,
      tableData: [{}],
      tableCols: [
        // { label: "ID", prop: "id", },
        { label: "Submitter Name", prop: "userName" },
        { label: "Submitter Phone", prop: "phone" },
        {
          label: "Submit Type",
          prop: "type",
          formatter: e =>
            e.type == 1 ? "Suggest" : e.type == 2 ? "Complaint" : "Else"
        },
        { label: "Submit Content", prop: "content" },
        { label: "Submit Images", prop: "img", type: "images" },
        { label: "Submission Time", prop: "ctime" }
      ],
      tableHandles: [],
      pagination: { limit: 10, offset: 1, total: 0 },
      checkBox: []
    };
  },
  created() {},
  mounted() {
    this.getData();
  },
  methods: {
    zeroFn() {
      this.pagination.limit = 10;
      this.pagination.offset = 1;
      this.pagination.total = 0;
    },
    async getData() {
      var res = await this.apis.feedback_list({
        pageNum: this.pagination.offset,
        pageSize: this.pagination.limit,
        type: this.searchData.type
      });
      var list = res.rows || [];
      this.tableData = list;
      this.pagination.total = res.total;
    }
  }
};
</script>

<style scoped></style>
